package pers.crayon.baseprogram.exception;

import lombok.Getter;
import lombok.Setter;
import pers.crayon.baseprogram.enums.ExplainEnum;

/**
 * 自定义用户操作异常
 *
 * @author roamay.com
 * @since 2021/9/24 12:02
 */
@Getter
@Setter
public class UserOperateException extends RuntimeException {

    /**
     * 错误码
     */
    protected String errorCode;
    /**
     * 错误信息
     */
    protected String errorMsg;

    public UserOperateException() {
        super();
    }

    public UserOperateException(String msg) {
        super(msg);
    }

    public UserOperateException(Throwable cause) {
        super(cause);
        this.errorMsg = cause.getMessage();
    }

    public UserOperateException(ExplainEnum explainEnum) {
        super(explainEnum.getErrMsg());
        this.errorCode = explainEnum.getCode();
        this.errorMsg = explainEnum.getErrMsg();
    }

    public UserOperateException(ExplainEnum explainEnum, Throwable cause) {
        super(explainEnum.getErrMsg(), cause);
        this.errorCode = explainEnum.getCode();
        this.errorMsg = explainEnum.getErrMsg();
    }
}
